{% extends 'base' %}

{% block title %}{{ wb.name }}的详细信息{% endblock %}

{% set current_page = '网站详情' %}

{% block content %}

{% if last_status is not defined %}
    {% set last_status = '' %}
{% endif %}

<ul class="breadcrumb">
    <li><a href="/">网站后台</a><span class="divider">/</span></li>
    <li><a href="/web/list">网站</a><span class="divider">/</span></li>
    <li class="active">{{ wb.name }}<span class="divider">/</span></li>
</ul>

    <div class="hero-unit">
        <code>网站</code>
        <h1>{{ wb.name }}</h1>
        <br/>
        <p>{{ wb.description }}</p>
        <a href="{{ wb.url }}" target="_blank" class="btn btn-large btn-inverse">访问&nbsp;&nbsp;&raquo;</a>
    </div>
    <div class="row-fluid">
        <div class="span4">
            <h4>所在服务器</h4>
            <p><b>{{ wb.server }}&nbsp;</b></p>
            <p><a href="/server/detail/{{ wb.server_ID }}/">查看服务器详细信息</a></p>
            <h4>最后测试时间</h4>
            <p><b class="text-info">{{ last_status.datetime }}</b></p>
        </div>
        <div class="span4">
            <h3>首页类型</h3>
            <p>标题：<b>{{ wb.title }}</b></p>
            <p>编码：<b>{{ wb.encoding }}</b></p>
            <p>页面类型：<b>{{ wb.content_type }}</b></p>
            <p>关键词测试：<b>
                {% if last_status.keywords == True %}
                    <span class="badge badge-success">通过</span>
                {% else %}
                    未找到
                    {% for keyword in last_status.keywords %}
                        <span class="badge badge-warning">{{ keyword }}</span>
                    {% endfor %}
                {% endif %}
            </b></p>
        </div>
        <div class="span4">
            <h3>页面加载时间</h3>
            <p>总时间：<b>{{ last_status.total_time }}</b></p>
            <p>连接时间：<b>{{ last_status.connect_time }}</b>&nbsp;秒</p>
            <p>域名解析时间：<b>{{ last_status.name_look_up }}</b>&nbsp;秒</p>
            <p>响应中途时间：<b>{{ last_status.start_transfer_time }}</b>&nbsp;秒</p>
        </div>
        </div>

    <div class="row-fluid">

    </div>
    <h3>近期访问时间</h3>
    <div class="row-fluid">
        <div class="span4">
            <p><b>总时间</b>(秒)<a href="/total/{{ oid }}/20/1/">更多</a></p>
            <canvas id="total_time_list" data-type="Line" data-list="{{ total_time_list }}" class="span4"></canvas>
        </div>
        <div class="span4">
            <p><b>连接时间</b>(秒)<a href="/connect/{{ oid }}/20/1/">更多</a></p>
            <canvas id="connect_time_list" data-type="Line" data-list="{{ connect_time_list }}" class="span4"></canvas>
        </div>
        <div class="span4">
            <p><b>域名解析时间</b>(秒)<a href="/lookup/{{ oid }}/20/1/">更多</a></p>
            <canvas id="name_look_up_list" data-type="Line" data-list="{{ name_look_up_list }}" class="span4"></canvas>
        </div>
    </div>
    <div class="clearfix"><br/><br/><br/></div>
    <div class="row-fluid">
        <div class="alert alert-block">
            <p><b>谨慎操作</b></p>
            <a href="/web/update/{{ wb._id }}/" class="btn btn-warning"><i class="icon-pencil"></i>修改信息</a>
            <a href="/web/delete/{{ wb._id }}/" class="btn btn-danger"><i class="icon-trash"></i>删除网站</a>
        </div>
    </div>




{% endblock %}

{% block foot %}
    <script>
        $("canvas").each(function(){
			var $canvas = $(this);
			var ctx = this.getContext("2d");
            var data = {
                labels : ['最新',1,2,3,4,5,6,7,8,'较旧'],
                datasets : [
                    {
                        fillColor : "rgba(151,187,205,0.5)",
                        strokeColor : "rgba(151,187,205,1)",
                        pointColor : "rgba(151,187,205,1)",
                        pointStrokeColor : "#fff",
                        data : $canvas.data('list')
                    }
                ]};
			var evalString = "new Chart(ctx)." + $canvas.data("type") + "(data);";
			eval(evalString);
		});
    </script>
{% endblock %}